home *** CD-ROM | disk | FTP | other *** search
- {******************************************}
- { TeeChart as a Console Application }
- { Copyright (c) 1997 by David Berneda }
- { All Rights Reserved }
- {******************************************}
- program TeeConso;
-
- {$IFDEF WIN32}
- {$APPTYPE CONSOLE}
- {$ENDIF}
-
- { This project is a console application, with no
- visual interface and no TForms.
-
- If you run this project, you'll see nothing
- appears on screen !!
-
- It creates a TChart component on-the-fly, and
- saves it as a bitmap image file: "c:\bar.bmp"
-
- The following "CreateChart" procedure can be
- used inside CGI applications, and overcomes the
- problem of no having a Parent for the Chart.
-
- The "trick" is to use a temporary invisible TForm
- component and set Chart1.Parent to it.
- }
- uses
- Forms,
- Chart,
- Series,
- SysUtils,
- ExtCtrls ;
-
- {$R *.RES}
-
- Procedure CreateChart;
- Var Chart1:TChart;
- Form1:TForm;
- Bar:TBarSeries;
- begin
- Form1:=TForm.Create(nil); { <-- fake parent }
- try
- Chart1:=TChart.Create(Form1); { <-- create Chart1 }
- try
- Chart1.Parent:=Form1; { <-- set fake parent }
-
- Bar:=TBarSeries.Create(Chart1); { <-- create Series }
- Chart1.AddSeries( Bar ); { <-- add to Chart1 }
- Bar.FillSampleValues(10); { <-- some values... }
-
- { Now we can , for example, save the
- Chart to a bitmap image file.
- }
- Chart1.SaveToBitmapFile('c:\bar.bmp'); { <-- save ! }
- finally
- Chart1.Free;
- end;
- finally
- Form1.Free;
- end;
- end;
-
- begin
- try
- CreateChart;
- except
- on E:Exception do { just in case something fails... }
- Application.ShowException(E);
- end;
- Application.Run;
- end.
-